package com.example.emailWeb.ntru.encrypt;


public class NtruProxyParameters {
    public static final NtruProxyParameters APR2011_439 = new NtruProxyParameters(439,3,256, 146, 130, 126, 128, 12, 32, 9, true, new byte[]{0, 7, 101}, true, false, "SHA-256");
    //之所以把q=4,怕后续算coeffs的时候，超出int的表示范围。
    // 解决办法：可以直接把coeffs改成long类型；或者在IntegerPolynomial,提供转long的方法
    public enum TernaryPolynomialType {SIMPLE, PRODUCT}; //product 积

    public int N, p, q, df, df1, df2, df3;
    int dr, dr1, dr2, dr3, dg, llen, maxMsgLenBytes, db, bufferLenBits, bufferLenTrits, dm0, maxM1, pkLen, c, minCallsR, minCallsMask;
    boolean hashSeed;
    byte[] oid;
    boolean sparse;
    boolean fastFp;
    EncryptionParameters.TernaryPolynomialType polyType; //三元多项式类型
    public String hashAlg;
    public NtruProxyParameters(int N, int p, int q, int df, int dm0, int maxM1, int db, int c, int minCallsR, int minCallsMask, boolean hashSeed, byte[] oid, boolean sparse, boolean fastFp, String hashAlg) {
        this.N = N;
        this.p = p;
        this.q = q;
        this.df = df;
        this.db = db;
        this.dm0 = dm0;
        this.maxM1 = maxM1;
        this.c = c;
        this.minCallsR = minCallsR;
        this.minCallsMask = minCallsMask;
        this.hashSeed = hashSeed;
        this.oid = oid;
        this.sparse = sparse;
        this.fastFp = fastFp;
        this.polyType = EncryptionParameters.TernaryPolynomialType.SIMPLE;
        this.hashAlg = hashAlg;
        init();
    }
    private void init() {
        dr = df;
        dr1 = df1;
        dr2 = df2;
        dr3 = df3;
        dg = N / 3;
        llen = 1;   // ceil(log2(maxMsgLenBytes))
        if (maxM1 > 0)
            maxMsgLenBytes = (N-1)*3/2/8 - llen - db/8;   // only N-1 coeffs b/c the constant coeff is not used
        else
            maxMsgLenBytes = N*3/2/8 - llen - db/8;
        bufferLenBits = (N*3/2+7)/8*8 + 1;
        bufferLenTrits = N - 1;
        pkLen = db;
    }
}
